package com.example.lambdaTest;

import javax.swing.*;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;

public class Main {
    public static void main(String[] args) {
        var planets = new String[]{"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"};
        System.out.println(Arrays.toString(planets));
        System.out.println("Sorted in dictionary order:");
        Arrays.sort(planets);
        System.out.println(Arrays.toString(planets));
        System.out.println("Sorted by length:");
        Arrays.sort(planets, (first, second) -> first.length() - second.length());
//        Arrays.sort(planets, Comparator.comparingInt(String::length));
        System.out.println(Arrays.toString(planets));

        var timer = new Timer(1000, event -> System.out.println("the time is " + new Date()));
        timer.start();

        JOptionPane.showMessageDialog(null, "Quit program");
        System.exit(0);


//        Path first = Path.of("/usr/bin");
//        Comparator<String> comp = (first, second) -> first.length() - second.length()
//        报错：Variable 'first' is already defined in the scope


    }
}
